def relaxation(L, C, M, c):
    i = 0
    for cycle in L:
	for k in range(len(c)):
	    for l in range(len(cycle)):
		if c[k] == cycle[l] and c[(k+1)%len(c)] == cycle[(l-1)%len(cycle)]:
		    C[i] -= M[c[k]][c[(k+1)%len(c)]]
	i += 1
